package com.ly.lypopupwindowdemo.views;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;

import com.ly.lypopupwindowdemo.R;
import com.ly.lypopupwindowdemo.util.PxUtils;

/**
 * Created by liying on 2017/7/19.
 * 参考
 * http://blog.csdn.net/zsp765098084/article/details/52944293
 */

public class LyCirclePercentView extends View {

    private Context context;
    private float mRadius;
    private float mStrokeWidth;
    private int firstColor;
    private int secondColor;
    private int thirdColor;
    private float firstPercent;
    private float secondPercent;
    private float thirdPercent;


    public LyCirclePercentView(Context context) {
        this(context, null);
    }

    public LyCirclePercentView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public LyCirclePercentView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        this.context = context;
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LyCirclePercentView, defStyleAttr, 0);

        try {
            mRadius = a.getDimension(R.styleable.LyCirclePercentView_radius2, PxUtils.dpToPx(100, context));
            mStrokeWidth = a.getDimension(R.styleable.LyCirclePercentView_strokeWidth2, PxUtils.dpToPx(30, context));

            firstColor = a.getColor(R.styleable.LyCirclePercentView_firstColor, Color.YELLOW);
            secondColor = a.getColor(R.styleable.LyCirclePercentView_secondColor, Color.RED);
            thirdColor = a.getColor(R.styleable.LyCirclePercentView_thirdColor, Color.GREEN);

            firstPercent = a.getFloat(R.styleable.LyCirclePercentView_firstPercent, (float) 33.33);
            secondPercent = a.getFloat(R.styleable.LyCirclePercentView_secondPercent, (float) 33.33);
            thirdPercent = a.getFloat(R.styleable.LyCirclePercentView_thirdPercent, (float) 33.33);

        } finally {
            a.recycle();
        }
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    }
}
